package com.gof.example.proxy.virtual;

import java.util.concurrent.ConcurrentHashMap;

/**
 * Created with IntelliJ IDEA.
 * Created by zhiyuan on 2018/5/9 11:19.
 * haiming.fei@tongdun.cn
 */
public abstract class AbstractCrawler {

    protected static final String[] suffixs = {".jpg", ".png", ".gif"};
    protected static ConcurrentHashMap<String, String> maps = new ConcurrentHashMap<>();
    private HttpClient client;

    public AbstractCrawler() {
        client = new HttpClient();
    }

    abstract void crawl(String url);

    public String view() {
        String key = "image" + (int) (9 * Math.random());
        return maps.get(key);
    }

    void init() {
        client.initHttp();
        client.startHttp();
    }
}
